<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#--引入外部文件-->
    <#include "../common/header.ftl">
    <script>
        $(function () {
            $(".becomeMember").click(function () {
                var user = $(this).data("json")
                $.post("/user/vip.do",{id:user.id , vip: true},function (data) {
                    console.log(data);
                   if(data.success){
                       window.location.reload();
                   }
                })
            })
            $(".lostMember").click(function () {
                var user = $(this).data("json")
                $.post("/user/vip.do",{id:user.id , vip: false},function (data) {
                    console.log(data);
                    if(data.success){
                        window.location.reload();
                    }
                })
            })
        })
    </script>
</head>
<body>

<div class="container" style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">用户管理</h1>
                </div>
            </div>
            <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/user/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <#--<a href="javascript:" class="btn btn-success inputBtn">
                    <span class="glyphicon glyphicon-plus"></span>  添加
                </a>-->
            </form>

            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>邮箱</th>
                    <th>昵称</th>
                    <th>头像</th>
                    <th>性别</th>
                    <th>地区</th>
                    <th>签名</th>
                    <th>会员</th>
                </tr>
                <#--使用Freemark的指令完成循环迭代-->
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.email}</td>
                        <td>${entity.nickName}</td>
                        <td><img src="${entity.headImgUrl}" width="30px" /></td>
                        <td>
                            <#if entity.gender??>
                                <#if entity.gender==-1>
                                    保密
                                    <#elseif entity.gender==0>
                                     女
                                    <#elseif entity.gender==1>
                                     男
                                </#if>
                            </#if>
                        </td>
                        <td>${entity.place!}</td>
                        <td>${entity.sign!}</td>
                        <td>
                            <#if entity.vip??>
                                <#if entity.vip == false>
                                    非会员
                                    <#elseif entity.vip == true>
                                    会员
                                </#if>
                            </#if>
                        </td>
                        <td>
                            <a href="javascript:" class="btn btn-success becomeMember" data-json='${entity.json}'>
                                <span class=" glyphicon">成为会员</span>
                            </a>
                            <a href="javascript:" class="btn btn-default lostMember" data-json='${entity.json}'>
                                <span class=" glyphicon">失去会员</span>
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>

            <#include "../common/page.ftl">
        </div>
    </div>
</div>


</body>
</html>